package com.localjoycommunity.cpdj.project.system.domain;

import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.localjoycommunity.cpdj.framework.aspectj.lang.annotation.Excel;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import java.util.Date;
import java.util.List;

/**
 * 心愿 活动对象 activity_wish
 *
 * @author aqie
 * @date 2020-11-29
 */
public class ActivityWish {
    private static final long serialVersionUID = 1L;

    /**
     * $column.columnComment
     */
    private Long id;

    /**
     * 标题
     */
    @Excel(name = "标题")
    private String title;

    /**
     * 1-wish 2-party
     */
    @Excel(name = "1-wish 2-party")
    private Integer type;

    /**
     * 上架状态，0：未上架  1：已上架
     */
    @Excel(name = "上架状态，0：未上架  1：已上架")
    private String shelfStatus;

    /**
     * 栏目展示状态 0：不展示  1：展示
     */
    @Excel(name = "栏目展示状态 0：不展示  1：展示")
    private String showStatus;

    /**
     * top_status(置顶状态  0：不置顶，1：置顶)
     */
    @Excel(name = "top_status(置顶状态  0：不置顶，1：置顶) ")
    private String topStatus;

    /**
     * 1:线上活动，2：线下活动
     */
    private String activityType;

    /**
     * 访问人数
     */
    @Excel(name = "访问人数")
    private Long visitNum;

    @Excel(name = "总人数")
    private Long totalPeople;

    /**
     * 剩余人数
     */
    @Excel(name = "剩余人数")
    private Long remainNum;

    /**
     * 活动地址
     */
    @Excel(name = "活动地址")
    private String activityPlace;

    /**
     * 封面
     */
    @Excel(name = "封面")
    private String cover;

    /**
     * 报名开始时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "报名开始时间", width = 30, dateFormat = "yyyy-MM-dd")
    private Date applyStartTime;

    /**
     * 报名结束时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "报名结束时间", width = 30, dateFormat = "yyyy-MM-dd")
    private Date applyEndTime;

    /**
     * 开始时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "开始时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    private Date startTime;

    /**
     * 结束时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "结束时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    private Date endTime;

    /**
     * 描述
     */
    @Excel(name = "描述")
    private String description;

    /**
     * 创建时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    /**
     * 更新时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField(exist = false)
    private Date updateTime;

    @TableField(exist = false)
    private List<WishList> wishLists;

    @TableField(exist = false)
    private int isApplyPartyActivity = 0;
    /**
     * 活动当前状态
     * 0：未开始 1：报名中 2：进行中(或已认领) 3：已结束
     */
    @TableField(exist = false)
    private Integer status;

    public int getIsApplyPartyActivity() {
        return isApplyPartyActivity;
    }

    public void setIsApplyPartyActivity(int isApplyPartyActivity) {
        this.isApplyPartyActivity = isApplyPartyActivity;
    }

    public Integer getStatus() {
        if (applyStartTime == null || applyEndTime == null || startTime == null || endTime == null) {
            return 0;
        }
        Date now = new Date();
        if (type == 2) {
            if (now.getTime() >= applyStartTime.getTime() && now.getTime() <= applyEndTime.getTime() && remainNum > 0) {
                return 1;
            } else if (now.getTime() > startTime.getTime() && now.getTime() < endTime.getTime()
                    && remainNum > 0) {
                return 2;
            } else if (now.getTime() > endTime.getTime() || remainNum == 0) {
                return 3;
            } else {
                return 0;
            }
        } else {
            if (now.getTime() > endTime.getTime() || remainNum == 0) {
                return 3;
            } else {
                return 2;
            }
        }
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public String getShelfStatus() {
        return shelfStatus;
    }

    public void setShelfStatus(String shelfStatus) {
        this.shelfStatus = shelfStatus;
    }

    public String getShowStatus() {
        return showStatus;
    }

    public void setShowStatus(String showStatus) {
        this.showStatus = showStatus;
    }

    public String getTopStatus() {
        return topStatus;
    }

    public void setTopStatus(String topStatus) {
        this.topStatus = topStatus;
    }

    public Long getVisitNum() {
        return visitNum;
    }

    public void setVisitNum(Long visitNum) {
        this.visitNum = visitNum;
    }

    public Long getRemainNum() {
        return remainNum;
    }

    public void setRemainNum(Long remainNum) {
        this.remainNum = remainNum;
    }

    public String getActivityPlace() {
        return activityPlace;
    }

    public void setActivityPlace(String activityPlace) {
        this.activityPlace = activityPlace;
    }

    public String getCover() {
        return cover;
    }

    public void setCover(String cover) {
        this.cover = cover;
    }

    public Date getApplyStartTime() {
        return applyStartTime;
    }

    public void setApplyStartTime(Date applyStartTime) {
        this.applyStartTime = applyStartTime;
    }

    public Date getApplyEndTime() {
        return applyEndTime;
    }

    public void setApplyEndTime(Date applyEndTime) {
        this.applyEndTime = applyEndTime;
    }

    public Date getStartTime() {
        return startTime;
    }

    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }

    public Date getEndTime() {
        return endTime;
    }

    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public List<WishList> getWishLists() {
        return wishLists;
    }

    public void setWishLists(List<WishList> wishLists) {
        this.wishLists = wishLists;
    }

    public Long getTotalPeople() {
        return totalPeople;
    }

    public void setTotalPeople(Long totalPeople) {
        this.totalPeople = totalPeople;
    }

    public String getActivityType() {
        return activityType;
    }

    public void setActivityType(String activityType) {
        this.activityType = activityType;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
                .append("id", getId())
                .append("title", getTitle())
                .append("type", getType())
                .append("shelfStatus", getShelfStatus())
                .append("showStatus", getShowStatus())
                .append("topStatus", getTopStatus())
                .append("visitNum", getVisitNum())
                .append("remainNum", getRemainNum())
                .append("activityPlace", getActivityPlace())
                .append("cover", getCover())
                .append("applyStartTime", getApplyStartTime())
                .append("applyEndTime", getApplyEndTime())
                .append("startTime", getStartTime())
                .append("endTime", getEndTime())
                .append("description", getDescription())
                .append("createTime", getCreateTime())
                .append("updateTime", getUpdateTime())
                .toString();
    }
}
